const { getorderservice, getorderseachservice, deleorderservice } = require('../../service/main/order')
module.exports = {
    async getorder(ctx, next) {
        const rudata = await getorderservice({})
        ctx.body = {
            code: 200,
            msg: '成功',
            data: rudata
        }
    },
    async seachorder(ctx, next) {
        const { orderid, userid, productid, createdAt } = ctx.request.body
        console.log(orderid, userid, productid, createdAt)
        const rudata = await getorderseachservice(orderid, userid, productid)
        ctx.body = {
            code: 200,
            msg: '成功',
            data: rudata
        }
    },
    async delorder(ctx, next) {
        const { id } = ctx.request.body
        const rudata = await deleorderservice(id)
        if (rudata[0]) {
            ctx.body = {
                code: 200,
                msg: '成功',
            }
        } else {
            ctx.body = {
                code: 200,
                msg: '失败',
            }
        }
    }
}